import React from "react";
import { View, StyleSheet, Platform } from "react-native";
import JDVideo from "../../components/JDVideo";
//import { Util } from "@marslibs/yfereact-freetemplate-common";
 const countDownData = {
  text: {
    middleType: "J_TEXT_AREA",
    type: "text",
    value: {
      text: "111|222|333|444|你好嗎阿達尼發發發防輻射首付舒服舒服舒服舒服是的郭德綱",
      dataSourceType: 0
    }
  },
  bt1PositionLeft: {
    middleType: "J_TEXT_AREA",
    type: "text",
    value: {
      text: "90",
      dataSourceType: 0
    }
  },

  bt1PositionTop: {
    middleType: "J_TEXT_AREA",
    type: "text",
    value: {
      text: "-20",
      dataSourceType: 0
    }
  },
  bk: {
    middleType: "J_LINK_IMAGE",
    type: "image",
    value: {
      imageHeight: "594",
      imageUrl:
        "http://img14.360buyimg.com/zx/jfs/t1/106462/2/10671/4106/5e21704dEdb70bc3f/a6d1cdfa64f5e294.jpg",
      dataSourceType: 0,
      imageWidth: "750"
    }
  },
 

  fontColor: {
    middleType: "J_TEXT_AREA",
    type: "text",
    value: {
      text: "blue",
      dataSourceType: 0
    }
  },
  fontSize: {
    middleType: "J_TEXT_AREA",
    type: "text",
    value: {
      text: "20",
      dataSourceType: 0
    }
  },
  bgHeight: {
    middleType: "J_TEXT_AREA",
    type: "text",
    value: {
      text: "80",
      dataSourceType: 0
    }
  }
};
export default class Example extends React.Component {
  constructor(props) {
    super(props);
  }
  render() {
    let bk;
    let textTitle;
    let bgHeight;
    let bt1PositionLeft;
    let bt1PositionTop;
    let fontColor;
    let fontSize;
    if (Platform.OS == "web") {
     // alert("web端2");
      const jApp = document.getElementById("m_common_content");
      if (!jApp) {
        console.error("m_common_content不存在");
      } else {
        const floorId = jApp.getAttribute("id");
        const floorData = window.floorData ? window.floorData[floorId] : null;
        if (!floorData) {
          console.error("floorData楼层数据获取失败");
        } else {
          bk = floorData.bk.value;
          textTitle=floorData.text.value;
          fontColor=floorData.fontColor.value.text;
          bgHeight = parseInt(floorData.bgHeight.value.text);
          bt1PositionLeft = parseInt(floorData.bt1PositionLeft.value.text);
          bt1PositionTop = parseInt(floorData.bt1PositionTop.value.text);
          fontSize=parseInt(floorData.fontSize.value.text);
        }
      }
    } else {
      if (!Util.getNodeText(this.props.data, "bk")) return <View></View>;
      bk = Util.getNodeText(this.props.data, "bk")? Util.getNodeText(this.props.data, "bk"): 0;
      if (!Util.getNodeText(this.props.data, "text")) return <View></View>;
      textTitle = Util.getNodeText(this.props.data, "text")? Util.getNodeText(this.props.data, "text"): 0;
      if (!Util.getNodeText(this.props.data, "bgHeight")) return <View></View>;
      bgHeight = parseInt(Util.getNodeText(this.props.data, "bgHeight").text)? parseInt(Util.getNodeText(this.props.data, "bgHeight").text): 0;
      if (!Util.getNodeText(this.props.data, "bt1PositionLeft"))return <View></View>;
      bt1PositionLeft = parseInt( Util.getNodeText(this.props.data, "bt1PositionLeft").text)? parseInt(Util.getNodeText(this.props.data, "bt1PositionLeft").text): 0;
      if (!Util.getNodeText(this.props.data, "bt1PositionTop"))return <View></View>;
      bt1PositionTop = parseInt( Util.getNodeText(this.props.data, "bt1PositionTop").text)? parseInt(Util.getNodeText(this.props.data, "bt1PositionTop").text): 0;
      if (!Util.getNodeText(this.props.data, "fontColor"))return <View></View>;
      fontColor = Util.getNodeText(this.props.data, "fontColor")? Util.getNodeText(this.props.data, "fontColor"): 0;
      if (!Util.getNodeText(this.props.data, "fontSize"))return <View></View>;
      fontSize = parseInt( Util.getNodeText(this.props.data, "fontSize").text)? parseInt(Util.getNodeText(this.props.data, "fontSize").text): 0;
    }
    return (
      <JDVideo
        imagebk={countDownData.bk.value.imageUrl}
        textTitle={countDownData.text.value.text}
        bgHeight={parseInt(countDownData.bgHeight.value.text)}
        bt1PositionLeft={parseInt(countDownData.bt1PositionLeft.value.text)}
        bt1PositionTop={parseInt(countDownData.bt1PositionTop.value.text)}
        fontSize={parseInt(countDownData.fontSize.value.text)}
        fontColor={countDownData.fontColor.value.text}
        // imagebk={bk.imageUrl}
        // textTitle={textTitle.text}
        // bgHeight={bgHeight}
        // bt1PositionLeft={bt1PositionLeft}
        // bt1PositionTop={bt1PositionTop}
        // fontColor={fontColor}
        // fontSize={fontSize}
      ></JDVideo>
    );
  }
}
